<?php
class C_ReportManager extends Controller {
    
    function __construct() {        
        parent::Controller();
        $this->logger = LoggerManager::getLogger('modules.report.controller.C_ReportManager');
        $this->view->path = 'report_manager';    
    }
    
    function actionHandle() {
        $result = array (
            'error'     => array('code'     => CoreErrorCode::NORMAL,
                                'message'	=> ''),
            'result'    => '');
        
        try {
             $name = $_POST['reportName'];
             $action = 'action' . $_POST['actionName'];
             
             $fileLoader = new HISFileLoader();
             $reportController = $fileLoader->getObj('C_' . $name);
             
             if (method_exists($reportController, $action)) {
                 $result['result'] = $reportController->$action();    
             } else {
                 throw new Exception("The method $action of class C_$name does not exist");
             }             
        } catch (Exception $e) {
             $this->logger->error($e->getMessage());
             $result['error']['code'] = CoreErrorCode::COMMON_ERROR;
             $result['error']['message'] = CoreErrorCode::getErrorMess();
        }
        
        return json_encode($result);
    }
    

    public function actionViewPaymentReport() {
        return $this->view->render('report_list.html');
    }
    
}